package models

import "gorm.io/gorm"

type Trade struct {
	gorm.Model
	Name       string  `json:"name"`
	db         *gorm.DB `json:"-"`
}

func (Trade) TableName() string {
	return "products"
}
func (p *Trade) FindByID(product_id uint) (model *Trade, err error) {
	model = &Trade{}
	result := p.db.First(model)
	err = result.Error
	return
}

func (p Trade) FindByTradeID(page, rows int, category_id uint) (pages Pages, error error) {
	panic("implement me")
}

type ITrade interface {
	FindByID(product_id uint) (*Trade, error)
	FindByTradeID(page, rows int, category_id uint) (pages Pages, error error)
}

func NewTrade(db *gorm.DB) ITrade {
	return &Trade{db:db}
}
